<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateQiiLemmaTinyTable extends Migration
{
    /**
     * Schema table name to migrate
     * @var string
     */
    public $set_schema_table = 'qii_lemma_tiny';

    /**
     * Run the migrations.
     * @table qii_lemma_tiny
     *
     * @return void
     */
    public function up()
    {
        if (Schema::hasTable($this->set_schema_table)) return;
        Schema::create($this->set_schema_table, function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->increments('id')->comment('词条ID');
            $table->unsignedInteger('uid')->default('0')->comment('添加此词条的作者ID');
            $table->string('title', 60)->default('')->comment('词条名称');
            $table->unsignedBigInteger('crc_title')->default('0')->comment('词条名称数字化');
            $table->unsignedInteger('viewnum')->default('0')->comment('查看次数统计');
            $table->unsignedInteger('lemma_length')->default('0')->comment('词条长度');
            $table->unsignedInteger('counter')->default('0')->comment('数据量统计');
            $table->unsignedInteger('sortrank')->default('0')->comment('排序');
            $table->unsignedInteger('modified')->default('0')->comment('添加/修改时间');
            $table->unsignedTinyInteger('status')->default('1')->comment('状态 (0已删除,1正常)');

            $table->index(["crc_title", "status"], 'crc_sta');

            $table->index(["sortrank"], 'rank');

            $table->unique(["title"], 'tit');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
     public function down()
     {
       Schema::dropIfExists($this->set_schema_table);
     }
}
